package com.dayuanit.dy17.atm.interceptor;

import com.dayuanit.dy17.atm.service.IRedisService;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ATMRequestCountInterceptor extends HandlerInterceptorAdapter {

    public ATMRequestCountInterceptor() {
        System.out.println("-------ATMRequestCountInterceptor()---------");
    }

    @Resource(name="redisServiceTmpleteImpl")
    private IRedisService redisService;

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println("----------ATMRequestCountInterceptor pre------------");
        String requestURI = request.getRequestURI();

        redisService.save4CountRequestURI(requestURI);
        return true;
    }
}
